﻿using Microsoft.EntityFrameworkCore;

namespace Zws.Dapper.Interfaces
{
    public interface IEFRepository<TDbContext, TEntity>
        where TDbContext : DbContext
        where TEntity : BaseEntity
    {
        /// <summary>
        /// 单条插入
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
         Task AddAsync(TEntity entity);
        /// <summary>
        /// 批量插入
        /// </summary>
        /// <param name="entities"></param>
        /// <returns></returns>
         Task AddListAsync(List<TEntity> entities);
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity"></param>
        void UpdateAsync(TEntity entity);
        /// <summary>
        /// 查单条
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<TEntity?> FindByIdAsync(string id);
        Task<TEntity?> FindAsync(Func<TEntity, bool> condition);
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        void DeleteSingle(TEntity entity);
        void DeleteRange(List<TEntity> entities);
    }
}
